Skip to content

upgrade: cursor package upgrade for Solid 2.0#869

Open
davedbase wants to merge 3 commits into
solidjs-community:nextfrom
davedbase:update/v2/cursor
Open

upgrade: cursor package upgrade for Solid 2.0#869
davedbase wants to merge 3 commits into
solidjs-community:nextfrom
davedbase:update/v2/cursor

Conversation

@davedbase
Copy link
Copy Markdown
Member

@davedbase davedbase commented May 4, 2026

Solid 2.0 migration

  • createEffect updated to the split compute/apply model — cleanup is returned from apply instead of onCleanup
  • isServer import moved from solid-js/web@solidjs/web
  • Tests updated with flush() after createRoot and each signal write, since Solid 2.0 defers effects by default
  • Peer deps bumped to solid-js@^2.0.0-beta.10 + @solidjs/web@^2.0.0-beta.10

New primitives

  • makeBodyCursor(cursor) / makeElementCursor(target, cursor) — imperative, non-reactive; call anywhere, get a cleanup function back. makeBodyCursor delegates to makeElementCursor(document.body, cursor) to avoid duplication
  • createDragCursor(target, options?) — sets "grab" on the element and switches to "grabbing" on the body during drag. The body-targeting trick is necessary because element inline styles beat body inline styles even with !important, so the element cursor is cleared during drag to let the body cursor inherit through
  • cursorRef(cursor) — ref factory for <div ref={cursorRef("pointer")}>, accepts a static value or signal

Summary by CodeRabbit

Release Notes

  • Breaking Changes

    • Requires Solid.js v2.0-beta.10+. Peer dependency constraints updated.
  • New Features

    • Four new cursor management functions now available.
    • Drag cursor support with grab/grabbing behavior options.
    • JSX ref factory for integrating cursor styling directly in templates.
  • Documentation

    • README expanded with API overview and usage examples for all cursor utilities.

Review Change Stack

@davedbase davedbase added this to the Solid 2.0 Migration milestone May 4, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: b3b4f6e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solid-primitives/cursor Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@davedbase davedbase changed the title upgrade: history package upgrade for Solid 2.0 upgrade: cursor package upgrade for Solid 2.0 May 4, 2026
@davedbase davedbase marked this pull request as ready for review May 23, 2026 21:14
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bce49bdc-6b3e-4a9d-b2eb-8ae821d526b4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cursor/README.md`:
- Line 11: Update the top-line description in the README to mention both
reactive and imperative usage instead of saying "reactive-only": change the
sentence that currently reads "Primitives for setting the CSS cursor property
reactively." to a short phrase that covers both patterns (e.g., "Utilities for
setting the CSS cursor property via reactive primitives and imperative APIs").
Reference the package's reactive primitives and the new imperative functions
makeBodyCursor and makeElementCursor in the sentence so readers know both usage
modes are supported.

In `@packages/cursor/src/index.ts`:
- Around line 190-204: When the observed target goes falsy the effect currently
returns early and removes listeners without resetting dragging, which can leave
dragging true and the cursor stuck; update the createEffect callback that uses
access(target) so that when el is falsy you call setDragging(false) before
returning. Specifically, in the createEffect(() => access(target), el => { ...
}) block add a branch for !el that invokes setDragging(false) (and then returns)
so any in-progress drag is cleared when the target unmounts; keep the existing
onDown/onUp listener logic and cleanup for the case when el exists.
- Around line 80-85: The current restore writes target.style.cursor =
overwritten which loses any previous !important priority; capture the prior
priority and value via target.style.getPropertyValue("cursor") and
target.style.getPropertyPriority("cursor") when you overwrite (inside
makeElementCursor) and restore using target.style.setProperty("cursor",
previousValue, previousPriority). Apply the same change to the other cleanup
sites that currently do target.style.cursor = overwritten (the other reactive
cleanup blocks with the same pattern) so they also preserve and restore the
original property priority.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d5865c68-bbee-4ca5-80cf-ee546de8289b

📥 Commits

Reviewing files that changed from the base of the PR and between 14d4ea9 and 8cfd3f8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .changeset/cursor-solid2-migration.md
  • packages/cursor/README.md
  • packages/cursor/package.json
  • packages/cursor/src/index.ts
  • packages/cursor/test/index.test.ts

Comment thread packages/cursor/README.md Outdated
Comment thread packages/cursor/src/index.ts
Comment thread packages/cursor/src/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant